package com.exception;

import lombok.Getter;

/**
 * 服务（业务）异常如“ 账号或密码错误 ”，该异常只做INFO级别的日志记录 @see WebMvcConfigurer
 */
public class ServiceException extends RuntimeException {

    @Getter
    private int code;

    public ServiceException() {
    }

    public ServiceException(String message) {
        super(message);
        this.code = ErrorCode.FAIL.code;

    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.code = ErrorCode.FAIL.code;
    }


    public ServiceException(ErrorCode code) {
        super(code.getMessage());

        this.code = code.getCode();
    }

    public ServiceException(ErrorCode code, Throwable cause) {
        super(cause);

        this.code = code.getCode();
    }

    public ServiceException(ErrorCode code, String message) {
        super(message);

        this.code = code.getCode();
    }

    public ServiceException(ErrorCode code, String message, Throwable cause) {
        super(message, cause);

        this.code = code.getCode();
    }
}
